package com.lizemin.jingdongmall.common;

import cn.hutool.core.exceptions.ExceptionUtil;
import com.lizemin.jingdongmall.entity.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author lzm
 * @date 2025/3/23 12:45
 * @description
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public RespBean handlerException(Exception e) {
        log.error("服务器异常：{}", ExceptionUtil.stacktraceToString(e));
        return RespBean.fail(e.getMessage());
    }

}
